#! /usr/bin/env node
const fs = require("fs");
const { program } = require('commander');
const curPath = process.cwd() + "/";
program
    .version('0.0.1')
    .option('-c, --car <fileData>', 'this is open fileData')
    .parse(process.argv);
const options = program.opts();
//16、如果文件不存在输出 文件不存在请检查路径
//15、cat 指令做容错判断
if (fs.existsSync(curPath + options.car)) {
    if (curPath + options.car.split(".")[1]==="undefined") {
        let fileData = fs.readFileSync(curPath + options.car, "utf-8")
        console.log(fileData);
    }else{
        console.log("请输入带后缀的文件名");
    }
} else {
    console.log("文件不存在请检查路径");
}